package com.yztstudy.utils;


import com.yztstudy.dto.UserDTO;

public class UserHolder {
    private static final ThreadLocal<UserDTO> tl = new ThreadLocal<>();

    /**
     * 添加User到ThreadLocal中
     */
    public static void saveUser(UserDTO user){
        tl.set(user);
    }

    /**
     * 获取User
     */
    public static UserDTO getUser(){
        return tl.get();
    }

    /**
     * 删除User
     */
    public static void removeUser(){
        tl.remove();
    }
}
